package com.kfm.servlet;

import com.kfm.service.AccountService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteAccount")
public class DeleteAccountServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");

        AccountService service = new AccountService();

        int row = service.deleteById(id);

        resp.setContentType("text/html;charset=utf-8");
        if (row > 0){
            resp.getWriter().write("<h1 style='color:green;'>id 为 " + id + " 的用户信息删除成功</h1>");
        }else{
            resp.getWriter().write("<h1 style='color:red;'>id 为 " + id + " 的用户信息删除失败</h1>");
        }
    }
}
